package cn.regexp.auth.mq;


import cn.regexp.auth.domain.LoginLog;
import cn.regexp.auth.mapper.UserMapper;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @author Regexp
 * @date 2024/7/4 20:42
 * @description MQ 登录日志监听器
 */
@Component
@RocketMQMessageListener(consumerGroup = "LoginLogGroup", topic = MQConstant.LOGIN_TOPIC)
public class MQLoginLogListener implements RocketMQListener<LoginLog> {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void onMessage(LoginLog message) {
        // 通过 MQ 进行异步登录日志记录
        userMapper.insertLoginLong(message);
    }
}
